package Ptolemaiosz;

public class Initializer {

	private int lastLevel;
	private Application application;

    public Initializer() {
        
        		SkeletonLogger.logCall();
		
		
		SkeletonLogger.logReturn();
    }
        
        public void setApplication(Application a)
        {
            	SkeletonLogger.logCall();
		
		
		SkeletonLogger.logReturn();
            application = a;
        }
        

	public void loadNextLevel() {
		SkeletonLogger.logCall();
		
                    //loadLevel(1); //ez mar nem objektumkozi kommunikacio nem kell most meg lefutnia
			
		SkeletonLogger.logReturn();
	}

	public void restartLevel() {
		SkeletonLogger.logCall();
		
                     //loadLevel(1); //ez mar nem objektumkozi kommunikacio nem kell most meg lefutnia
			
		SkeletonLogger.logReturn();
	}

	/**
	 * 
	 * @param levelNumber
	 */
	public void loadLevel(int levelNumber) {
		SkeletonLogger.logCall();
		
                        // pálya az illeszkedesvizsgalatra
                        //3 pályaszakasz 1-1 fallal
                        //az elso szakaszon az avatar
			if(levelNumber == 1)
                            {
                                //Palya letrehozasa
                                Level level = new Level();
                                level.setApplication(application);
                                LevelPartManager levelPartManager = application.getLevelPartManager();
                                
                                //Levelpartok letrehozasa
                                LevelPart levelpart1 = new LevelPart();
                                LevelPart levelpart2 = new LevelPart();
                                LevelPart levelpart3 = new LevelPart();
                                LevelPart emptyLevelPart = new LevelPart();
                                                              
                                //Falak letrehozasa
                                Wall wall1 = new Wall();
                                    WallPhysicalEntity wallphy1 = new WallPhysicalEntity();
                                        wallphy1.setPosition(null);
                                        wallphy1.setPolygon();
                                        wallphy1.setLevelPartManager(levelPartManager);
                                    wall1.setPhysicalEntity(wallphy1);
                                
                                Wall wall2 = new Wall();
                                    WallPhysicalEntity wallphy2 = new WallPhysicalEntity();
                                        wallphy2.setPosition(null);
                                        wallphy2.setPolygon();
                                        wallphy2.setLevelPartManager(levelPartManager);
                                    wall2.setPhysicalEntity(wallphy2);
                                    
                                Wall wall3 = new Wall();
                                    WallPhysicalEntity wallphy3 = new WallPhysicalEntity();
                                        wallphy3.setPosition(null);
                                        wallphy3.setPolygon();
                                        wallphy3.setLevelPartManager(levelPartManager);
                                    wall3.setPhysicalEntity(wallphy3);
                                    
                                Wall wall4 = new Wall();
                                    WallPhysicalEntity wallphy4 = new WallPhysicalEntity();
                                        wallphy4.setPosition(null);
                                        wallphy4.setPolygon();
                                        wallphy4.setLevelPartManager(levelPartManager);
                                    wall4.setPhysicalEntity(wallphy4);
                                                          
                                
                                //Falak megtanitasa a levelpartoknak
                                levelpart1.addWall(wall1);
                                levelpart2.addWall(wall2);
                                levelpart3.addWall(wall3);
                                emptyLevelPart.addWall(wall4);
                                
                                //Falak átadása elemetként is
                                levelpart1.addElement(wall1);
                                levelpart2.addElement(wall2);
                                levelpart3.addElement(wall3);
                                emptyLevelPart.addElement(wall4);
                                
                                //Ures szakasz atadasa a palyanak
                                level.setEmptyLevelPart(emptyLevelPart);
           
                                //kulcsok számának a rogzitese
                                level.setNumberOfKeys(0);
                                
                                //Levelpart szomszedsagok definialasa
                                LevelPart[][] neighbour2DArray = new LevelPart[2][2];
                                neighbour2DArray[0][0] = levelpart1;
                                neighbour2DArray[0][1] = levelpart2;
                                neighbour2DArray[1][0] = levelpart3;
                                neighbour2DArray[1][1] = emptyLevelPart;                                
                                                                                                
                                //Levelpartok megadasa a levelnek
                                level.setneighbour2DArray(neighbour2DArray);
                                
                                //Aktualis palyaszakasz beallitasa
                                level.setCurrentLevelPart(levelpart1);
                                
                                //Palya hozzarendelese az applicationhoz
                                application.setLevel(level);
                                
                                //Palya hozzarendelese a levelPart managerhez
                                levelPartManager.setLevel(level);
                                
                                //Avatár létrehozása
                                Avatar avatar =  new Avatar();
                                    AvatarPhysicalEntity avatarphy = new AvatarPhysicalEntity();
                                        avatarphy.setPosition(null);
                                        avatarphy.setPolygon();
                                        avatarphy.setLevelPartManager(levelPartManager);
                                     avatar.setPhysicalEntity(avatarphy);
                                     
                                //Avatár hozzáadása a levelhez
                                level.setAvatar(avatar);   
                                
                                
                                //Fizikanak megtanitjuk a palyat
                                application.getPhysics().setLevel(level);
                                
                            }
                        
                        //change_viewmode-hoz pálya
                        //3 pályaszakasz
                        //az első szakaszon 1 fal, az avatárral
                        
                        if(levelNumber == 2)
                            {
                                //Palya letrehozasa
                                Level level = new Level();
                                level.setApplication(application);
                                LevelPartManager levelPartManager = application.getLevelPartManager();
                                
                                //Levelpartok letrehozasa
                                LevelPart levelpart1 = new LevelPart();
                                LevelPart levelpart2 = new LevelPart();
                                LevelPart levelpart3 = new LevelPart();
                                LevelPart emptyLevelPart = new LevelPart();
                                                              
                                //Falak letrehozasa
                                Wall wall1 = new Wall();
                                    WallPhysicalEntity wallphy1 = new WallPhysicalEntity();
                                        wallphy1.setPosition(null);
                                        wallphy1.setPolygon();
                                        wallphy1.setLevelPartManager(levelPartManager);
                                    wall1.setPhysicalEntity(wallphy1);
                                Wall wall2 = new Wall();
                                    WallPhysicalEntity wallphy2 = new WallPhysicalEntity();
                                        wallphy2.setPosition(null);
                                        wallphy2.setPolygon();
                                        wallphy2.setLevelPartManager(levelPartManager);
                                    wall1.setPhysicalEntity(wallphy2);
                                
                                //Falak megtanitasa a levelpartoknak
                                levelpart1.addWall(wall1);
                                emptyLevelPart.addWall(wall2);
                                
                                //Falak átadása elementként is
                                levelpart1.addElement(wall1);
                                emptyLevelPart.addElement(wall2);
                                
                                //kulcsok számának a rogzitese
                                level.setNumberOfKeys(0);
                                
                                //Ures szakasz atadasa a palyanak
                                level.setEmptyLevelPart(emptyLevelPart);
     
                                //Levelpart szomszedsagok definialasa
                                LevelPart[][] neighbour2DArray = new LevelPart[2][2];
                                neighbour2DArray[0][0] = levelpart1;
                                neighbour2DArray[0][1] = levelpart2;
                                neighbour2DArray[1][0] = levelpart3;
                                neighbour2DArray[1][1] = emptyLevelPart;                                
                                                                                                
                                //Levelpartok megadasa a levelnek
                                level.setneighbour2DArray(neighbour2DArray);
                                
                                //Aktualis palyaszakasz beallitasa
                                level.setCurrentLevelPart(levelpart1);
                                
                                //Palya hozzarendelese az applicationhoz
                                application.setLevel(level);
                                
                                //Palya hozzarendelese a levelPart managerhez
                                levelPartManager.setLevel(level);
                                
                                //Avatár létrehozása
                                Avatar avatar =  new Avatar();
                                    AvatarPhysicalEntity avatarphy = new AvatarPhysicalEntity();
                                        avatarphy.setPosition(null);
                                        avatarphy.setPolygon();
                                        avatarphy.setLevelPartManager(levelPartManager);
                                     avatar.setPhysicalEntity(avatarphy);
                                     
                                //Avatár hozzáadása a levelhez
                                level.setAvatar(avatar);   
                                
                                
                                //Fizikanak megtanitjuk a palyat
                                application.getPhysics().setLevel(level);
                                
                            }
                        
                        
                        //1 palyaszakasz 1 fal 1 avatar
                        //pl a mozgas szimulaciohoz
                        if(levelNumber==3)
                        {
                            //Palya letrehozasa
                                Level level = new Level();
                                level.setApplication(application);
                                LevelPartManager levelPartManager = application.getLevelPartManager();
                                
                                //Levelpartok letrehozasa
                                LevelPart levelpart1 = new LevelPart();
                                                              
                                //Falak letrehozasa
                                Wall wall1 = new Wall();
                                    WallPhysicalEntity wallphy1 = new WallPhysicalEntity();
                                        wallphy1.setPosition(null);
                                        wallphy1.setPolygon();
                                        wallphy1.setLevelPartManager(levelPartManager);
                                    wall1.setPhysicalEntity(wallphy1);
                                    
                                //Falak megtanitasa a levelpartoknak
                                levelpart1.addWall(wall1);
                                
                                //Falak átadása elemetként is
                                levelpart1.addElement(wall1);
                                
                                //Ures szakasz atadasa a palyanak
                                
                                //Kulcsok létrehozása
                                level.setNumberOfKeys(0);
                                                                   
                                //Levelpart szomszedsagok definialasa
                                LevelPart[][] neighbour2DArray = new LevelPart[1][1];
                                neighbour2DArray[0][0] = levelpart1;           
                                                                                                
                                //Levelpartok megadasa a levelnek
                                level.setneighbour2DArray(neighbour2DArray);
                                
                                //Aktualis palyaszakasz beallitasa
                                level.setCurrentLevelPart(levelpart1);
                                
                                //Palya hozzarendelese az applicationhoz
                                application.setLevel(level);
                                
                                //Palya hozzarendelese a levelPart managerhez
                                levelPartManager.setLevel(level);
                                
                                //Avatár létrehozása
                                Avatar avatar =  new Avatar();
                                    AvatarPhysicalEntity avatarphy = new AvatarPhysicalEntity();
                                        avatarphy.setPosition(null);
                                        avatarphy.setPolygon();
                                        avatarphy.setLevelPartManager(levelPartManager);
                                     avatar.setPhysicalEntity(avatarphy);
                                     
                                //Avatár hozzáadása a levelhez
                                level.setAvatar(avatar);   
                                
                                //Fizikanak megtanitjuk a palyat
                                application.getPhysics().setLevel(level);
                        }
                        
                        
                        //1 palyaszakasz + az ures + 1 fal 1 kulcs 1 avatar
                        //collect key szekvenciahoz
                        if(levelNumber==4)
                        {
                            //Palya letrehozasa
                                Level level = new Level();
                                level.setApplication(application);
                                LevelPartManager levelPartManager = application.getLevelPartManager();
                                
                                //Levelpartok letrehozasa
                                LevelPart levelpart1 = new LevelPart();
                                LevelPart emptyLevelPart = new LevelPart();
                                                              
                                //Falak letrehozasa
                                Wall wall1 = new Wall();
                                    WallPhysicalEntity wallphy1 = new WallPhysicalEntity();
                                        wallphy1.setPosition(null);
                                        wallphy1.setPolygon();
                                        wallphy1.setLevelPartManager(levelPartManager);
                                    wall1.setPhysicalEntity(wallphy1);
                                    
                                //Falak megtanitasa a levelpartoknak
                                levelpart1.addWall(wall1);
                                
                                //Falak átadása elemetként is
                                levelpart1.addElement(wall1);
                                
                                level.setEmptyLevelPart(emptyLevelPart);
                                
                                //Kulcsok létrehozása
                                Key key1 = new Key();
                                        PhysicalEntity keyphy1 = new PhysicalEntity();
                                            keyphy1.setPosition(null);
                                            keyphy1.setPolygon();
                                            keyphy1.setLevelPartManager(levelPartManager);
                                    key1.setPhysicalEntity(keyphy1);
                                    key1.setLevel(level);
                                    
                               
                                //Kulcsok átadása
                                levelpart1.addElement(key1);
                                
                                //kulcsok számának a rogzitese
                                level.setNumberOfKeys(1);
                                
                                //Levelpart szomszedsagok definialasa
                                LevelPart[][] neighbour2DArray = new LevelPart[2][2];
                                neighbour2DArray[0][0] = levelpart1;
                                                 
                                //Levelpartok megadasa a levelnek
                                level.setneighbour2DArray(neighbour2DArray);
                                
                                //Aktualis palyaszakasz beallitasa
                                level.setCurrentLevelPart(levelpart1);
                                
                                //Palya hozzarendelese az applicationhoz
                                application.setLevel(level);
                                
                                //Palya hozzarendelese a levelPart managerhez
                                levelPartManager.setLevel(level);
                                
                                //Avatár létrehozása
                                Avatar avatar =  new Avatar();
                                    AvatarPhysicalEntity avatarphy = new AvatarPhysicalEntity();
                                        avatarphy.setPosition(null);
                                        avatarphy.setPolygon();
                                        avatarphy.setLevelPartManager(levelPartManager);
                                     avatar.setPhysicalEntity(avatarphy);
                                     
                                //Avatár hozzáadása a levelhez
                                level.setAvatar(avatar);   
                                
                                
                                //Fizikanak megtanitjuk a palyat
                                application.getPhysics().setLevel(level);
                        }                        
                        //1 palyaszakasz 1 ajto 1 avatar
                        //door interaction szekvenciahoz
                        if(levelNumber==5)
                        {
                            //Palya letrehozasa
                                Level level = new Level();
                                level.setApplication(application);
                                LevelPartManager levelPartManager = application.getLevelPartManager();
                                
                                //Levelpartok letrehozasa
                                LevelPart levelpart1 = new LevelPart();
                                                              
                                //Falak letrehozasa
                                Wall wall1 = new Wall();
                                    WallPhysicalEntity wallphy1 = new WallPhysicalEntity();
                                        wallphy1.setPosition(null);
                                        wallphy1.setPolygon();
                                        wallphy1.setLevelPartManager(levelPartManager);
                                    wall1.setPhysicalEntity(wallphy1);
                                    
                                //Falak megtanitasa a levelpartoknak
                                levelpart1.addWall(wall1);
                                
                                //Falak átadása elemetként is
                                levelpart1.addElement(wall1);
                                
                                //Kulcsok létrehozása                                   
                               
                                //Kulcsok átadása
                                
                                //kulcsok számának a rogzitese
                                level.setNumberOfKeys(0);
                                
                                //Ajtó létrehozása
                                Door door = new Door();
                                        PhysicalEntity doorphy = new PhysicalEntity();
                                            doorphy.setPosition(null);
                                            doorphy.setPolygon();
                                            doorphy.setLevelPartManager(levelPartManager);
                                    door.setPhysicalEntity(doorphy);
                                    door.setLevel(level);
                                    
                                //ajtó átadása
                                levelpart1.addElement(door);
                                   
                                                                   
                                //Levelpart szomszedsagok definialasa
                                LevelPart[][] neighbour2DArray = new LevelPart[2][2];
                                neighbour2DArray[0][0] = levelpart1;
                                                 
                                //Levelpartok megadasa a levelnek
                                level.setneighbour2DArray(neighbour2DArray);
                                
                                //Aktualis palyaszakasz beallitasa
                                level.setCurrentLevelPart(levelpart1);
                                
                                //Palya hozzarendelese az applicationhoz
                                application.setLevel(level);
                                
                                //Palya hozzarendelese a levelPart managerhez
                                levelPartManager.setLevel(level);
                                
                                //Avatár létrehozása
                                Avatar avatar =  new Avatar();
                                    AvatarPhysicalEntity avatarphy = new AvatarPhysicalEntity();
                                        avatarphy.setPosition(null);
                                        avatarphy.setPolygon();
                                        avatarphy.setLevelPartManager(levelPartManager);
                                     avatar.setPhysicalEntity(avatarphy);
                                     
                                //Avatár hozzáadása a levelhez
                                level.setAvatar(avatar);   
                                
                                
                                //Fizikanak megtanitjuk a palyat
                                application.getPhysics().setLevel(level);
                        }                        
		SkeletonLogger.logReturn();
	}

}